/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package admin.beans;

import abstractClasses.AbstractFilterableEntityList;
import entities.PublicRelations;
import entities.User;
import facades.PublicRelationsFacade;
import facades.UserFacade;
import java.io.Serializable;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.event.Event;
import javax.faces.model.SelectItem;
import javax.inject.Inject;
import javax.inject.Named;
import qualifiers.EditedEntityEvent;
import qualifiers.PreEditEntityEvent;
import qualifiers.PreRemoveEntityEvent;
import qualifiers.RemovedEntityEvent;

/**
 *
 * @author Alvaro
 */
@Named(value = "adminPublicRelationshipsBean")
@SessionScoped
public class AdminPublicRelationsBean extends AbstractFilterableEntityList<PublicRelations, PublicRelationsFacade> implements Serializable {

    @Inject
    @PreRemoveEntityEvent
    private Event<PublicRelations> preRemovePublicRelationsEvent;
    @Inject
    @RemovedEntityEvent
    private Event<PublicRelations> removePublicRelationsEvent;
    @Inject
    @PreEditEntityEvent
    private Event<PublicRelations> preEditPublicRelationsEvent;
    @Inject
    @EditedEntityEvent
    private Event<PublicRelations> editedPublicRelationsEvent;
    @Inject
    private PublicRelationsFacade publicRelationsFacade;
    /**
     * Creates a new instance of AdminCompanyBean
     */
    public AdminPublicRelationsBean() {
    }
    


    @Override
    public String redirectToViewEntity() {
        return null;
    }
    
    public SelectItem[] getTrueFalseOptions() {
        SelectItem[] options = new SelectItem[3];
        options[0] = new SelectItem("", "Indiferente");
        options[1] = new SelectItem(Boolean.TRUE.toString(), "Sí");
        options[2] = new SelectItem(Boolean.FALSE.toString(), "No");
        return options;  
    }
    
    public void removeProfile(){
        preRemovePublicRelationsEvent.fire(getChosenEntity());
        publicRelationsFacade.remove(getChosenEntity().getUser().getPublicRelations());
        removePublicRelationsEvent.fire(getChosenEntity());
    }
    
    public void editProfile(){
        preEditPublicRelationsEvent.fire(getChosenEntity());
        publicRelationsFacade.edit(getChosenEntity().getUser().getPublicRelations());
        editedPublicRelationsEvent.fire(getChosenEntity());
    }
}
